<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .w {
        margin: 10px;
        float: left;
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <!-- <div id="app">
      <input type="text" v-model="city" />
      <input type="button" value="搜索" @click="search" />
      <div id="result">
        <div v-for="item in result" :key="item.date" class="w">
          <div>{{item.date}}</div>
          <div>{{item.low}}</div>
          <div>{{item.hight}}</div>
          <div>{{item.type}}</div>
        </div>
      </div>
    </div> -->

    <div id="app">
      <input type="text" v-model="city" />
      <input type="button" value="搜索" @click="search" />
      <div id="result">
        <div v-for="item in result" :key="item.date" class="w">
          <div>{{item.date}}</div>
          <div>{{item.low}}</div>
          <div>{{item.hight}}</div>
          <div>{{item.type}}</div>
        </div>
      </div>
    </div>
    <script src="../lib/vue.js"></script>
    <script src="../lib/jquery.js"></script>
    <script src="../lib/axios.js"></script>
    <script>
      // new Vue({
      //   el: '#app',
      //   data: {
      //     city: '深圳',
      //     result: [],
      //   },
      //   methods: {
      //     search: function () {
      //       let that = this
      //       let url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + this.city
      // $.getJSON(url, function (res) {
      //   that.result = res.data.forecast
      // })
      //     },
      //   },
      // })

      new Vue({
        el: '#app',
        data: {
          city: '深圳',
          result: [],
        },
        created: function () {
          this.search()
        },
        methods: {
          search: function () {
            let url = 'http://wthrcdn.etouch.cn/weather_mini?city=' + this.city

            axios.get(url).then((res) => {
              this.result = res.data.data.forecast
            })
          },
        },
      })
    </script>
  </body>
</html>
